before save method in server