Refactored properly