refactor/cleaned up code.