Switched from timeouts to callbacks for sql queries