Added some checks for variable emptiness