code cleanup and refactor