Refactoed code