Fix bug that overwrites a local variable