this logic could really use log.debug() messages