refactored visited array to a non-arbitrary size