first implementation with test function