added broken half-assed sql part