all three main functions are working. would like to refactor. must document better