Fixed errors with id query