first implementation and testing of functions