Fixed a typo and made code more secure