changed two functions and added documentation