wrap function in exists check