Better error msg and removed free var
Better error msg and removed free var