removed returns from for loops and some style changes