format and remove unused code