Fixing issue causing data to be emptied