Fixed stupid variable scope bug