update to database and rest key