big perf gain getting out of window scope
added some verification and namespace