start of mode inference