fixed some terrible code.