-refactored main