created functions and tested