added if condition when update is called