refactor code

reduce redis connections