added function contents and documentation