added checks for already declared variables