adapted eval_Q in Ccoder.py