Why is an "error: redefinition of [variable]" occurring every time I run code more than once?