Using inner function within another function