Added check for type on loop search