apply rules