fixed some minor bugs and added a comment