changed mate logic