Added more code to support devise from client