Added some query escapes for safety