Global variable working fine