Fixed data corruption bug