Splitting code in initialisation and calculation part