Tweaking Q code