Made database.rb more DRY