fixed a small bug in my code, code seems to work fine for 4 directions, should work for the other 4.