refact controller