Refactoring uncessory code