added corner check