included some more tests and tweaking of function definitions