You can totally define this as a function inside update() so that p and c are captured automatically by closure and you don't have to pass them in.