use before save fn