clean up some ugly ass code