refactoy code