updated comments. trying to understand inner function