maybe these 5 lines should go to a function as they are nearly the same for every corner