functions writen by the book