Added more comments to non recrusive solution.