cleaning some messy code