changed exsists() to more secure way.