removed useless code, added clarifying comments