Bug fix - undef variable