refactor; clean up code