add format method and update code