kind of fixed begin and define.  might infinite loop now