Refactored the database part, each database has his own function now.