slightly improved the check-for-bending function
made the neighbors function more readable and easier to understand