@SuppressWarnings("unchecked")
	public void addTag(String tag, String filePath){
		Picture picture = findById(filePath);
		if(picture != null){
			List<TagI> tags = new ArrayList<TagI>();
			try{
				tags = (List<TagI>) picture.getTags();
			}catch(Exception y){
				Log.getLogger().log(Level.INFO, "Couldn't get any tags from Pictur " +  picture);	
				tags = new ArrayList<TagI>();
			}

			Tag tagg = this.tagDao.findById(tag);
			if(tagg != null){
				List<PictureI> pics = new ArrayList<PictureI>();
				try{
					pics = (List<PictureI>) tagg.getPictures();
				}catch(Exception i){
					Log.getLogger().log(Level.INFO, "Couldn't get any pictures from Tag " + tagg);
				}
				if(!(pics.contains(picture))){
					beginTransaction();
					pics.add(picture);
					tagg.setPictures(pics);
					tags.add(tagg);
					picture.setTags(tags);
					this.tagDao.persist(tagg);
					commitTransaction();	
				}
			}else{
				beginTransaction();
				TagI newTag = new Tag();
				newTag.setTag(tag);
				List<PictureI> pictures = new ArrayList<PictureI>();
				pictures.add(picture);
				newTag.setPictures(pictures);
				List<TagI> taggs = new ArrayList<TagI>();
				try{
					taggs = (List<TagI>) picture.getTags();
				}catch(Exception u){
					Log.getLogger().log(Level.INFO, "Couldn't get any tags from Picture " + picture);
				}			
				taggs.add(newTag);
				picture.setTags(tags);
				persist(picture);
				entityManager.persist(newTag);
				commitTransaction();	
			}
		}
	}