fixed closure scoping issue