Refactoring: improve speed by removing 2 re and using deque to free memory