cleanup trailing whitespace, print statements
refactor moved code