Organized code, added more comments