Fixed quert and function for guidelines and deviation