cleaning up some terrible code