all this block could be moved in the else block below