Refactoring

Changed for Rails 4