add commenting and remove unused code