Refactored to be more rails-like