refactoring some code...