fixed duplication of variable in code