Setting value of form element from $form_state not working
This:

(isset($values['element1']))


will always return TRUE, since the form element exists, and therefore a value is always passed to the submit hander, even when the value is empty.

You likely want this:

!empty($values['element1'])