added documentation, fixed small insersion bug