Working functions, need to write documentation.