Refactored with hash