bug fix of apply