cleaned up some code and formatting