remove rails dependance and put all logic in one place