before edit query