Extract common method.

Change-Id: I0b1368110a228a835108ab7958b97be086bec7a6