removed useless code, added some more comments