refactored to remove an 'if' statement