refactord rails