Move arithmetic code to correct location