refactor coded for redis