weird bug, after alert variable works fine, else not