fix undefined variable / error logging