Moved hooks into functions making script neater and allowing isolated parameters to be passed to events at a later date