Simplified the setup code by combining some functions

Change-Id: I435cb3032f3b09cc209a3c36987105ebdfb6cd2b