added api documentation, fixed a bug in example 2