remove unused code and add comments