cleanup and refactoring. abstracting away console