final refactor and cleanup