messy code to work