Moved SQL to the Controller