moved SQL around