extracted if tree for creating widgets out to a function; changed fucntion to return true upon succes else false.