clean up some terrible code