cleanup some code to separate concerns more