organized code and cleaned up comments