Added definition of apply_closure