Refactored code. Externalized code from ImportCtrl