added function to save element to database