Fixed some logic and made it pretty