fix variables scope