Refactor devise