cleaned up code and refactored
cleaned up code