another sql bug fix