minimal refactor and clean up