added if condition when update is invoked