Update format and remove some redundant code