Re factored some stuff for better organisation