added functions and unit test