Refactor to reduce code smell