Made more efficient, less checks are needed for same solution