add a probably not correct alternating path function and make some stylistic changes