a bit of refactor
initial refactor. man i wrote terrible code a few months ago =)