bug fixing, add comments