Refactoring some code...