added some doc string and renamed some functions