cleanup
factor repetitive statements