abstract functions out

abstracted some functions out to clarify how the process is working,
added more concise documentation to the functions