removed debug statements and moved autodetection before block entry
check