Fixing app var scope issue