Improved CUP implementation