remove unused lines and format codes