cleanup
refactor to remove som duplicate lines of code