Fixed code to be more secure and added root object