refactored code...