fixed figure_id value checking and added anonymous function