added gen branches and moved regerssion into event loop