fixed sql query and labels