adding encryption and cleaning the code