Fix a $apply bug