Fixed bug with checkSideBoundaries not working properly