Added debugging code, limited variable scope