added variable checking + tests