moved code to method for better overwriting

Change-Id: I6c88d384ac0688cbaa52b39da573287fcf2ebfc1