added some level detection algorithms