fixed #1 - code cleanup to remove scope workaround