refactored some code...