add exception for missing identifier
move function
move common parts inside called function
use result id function