add comment and solve bugs