fixed a bug and adde comments