Refactored some Code