fix bug with new definition used undefined variables