Refactored database step