added root function with tests