Moved SQL to a function and parse now calls it