cleaning up messy code