REFACTOR CODE