Turning into functions + some testing - not final