Not a big change. Just moved some of the code in to it's own functions