fixed unintended memory overwrites