some bugs removed
better comments