More actions made into functions

Code is abit more readable now