update to handle all cases and reformat