This makes the assumption, once again, that only one quest is active at a time. Why not male it a view receiving the quest id as a parameter, and registering results for it only.