added function and tested