refactor to use appendSeparator in whole program