Bug with storing of variables