split large controller function