refactored, made a cleaner design for the database