Refactoring in database.go