refoctoring devise code