function and testing passed