working function passes all tests