complete restructure to rails