functions implemented and tested