ENYO-522 Abstract out duplicated code
Based on Aaron Tam's advise, pull out some duplicated code into private function.

Enyo-DCO-1.1-Signed-off-by: David Um david.um@lge.com