refactored database with type params