refactored some code....