only execute callback if it's not undefined