generic function for save entry