refactor to not make multiple scans on redis