cleaning up some smells of duplicate and complex code