Added Inner function and test