refactoring database step interaction into one location