check the return value and reformat