Refactored database methods