refactoring code...