Refactored the format class, fix #2