updated functionality for adding to database