improve code to update tags