added edit function for SM