Use conditional logic inside the constructor

Change-Id: I87a62ae22429c49984e2e7744f8878b537f8a890