This code is shite ATM, once it's working I'm going to rewrite it to be nice