added documentation and changed var names