some working function definitions with tests