Fixed another function and made code prettier