Refactored to use references