all functions written and tested