added base db and improved code