replace constants and reformat