fixed small error and made code a bit easier to read