refactored to not use return statements so Rails 4.1 still works