Move SQL to the Controller