Fixed minor SQL bug