fixed up corner finding code