renamed functions and added documentation