fixed scoping issue