added debug checks