fix error and improve style