abstracting update function