solve the messy code problem