Fixed problem with SQL escaping