Update database and add some function for security