Refactor redundant code

Use decorators.

Change-Id: I9c0367256dcac4c63a96120d5cd1abb6a41d863e