Fixed variable scope error