optimize the mask animation