Refactored main() and removed unused imports