mainFunction working with SQL

Made correction to mainFunction so that it correctly uses SQL and SQL’s
new its variable paths.