Organized code and added comments