cleaned up file and added some explanation of what the functions do