added functions and testing