fixing conditional assignment