attendance query not working