Reduce code duplication a bit

Change-Id: I620592f397b7b83d6cf9e2ce0ea8ff7a1301cfbc
Merge "Reduce code duplication a bit"