fixed bugs in APPLY; still a bug in RETURN to fix