Moved addid function so that it now adds the id to the database if it does not exist in the database