fix bug with redeclarated variable