bug fix on visit length and removed unused imports