variables scope problem