add ternary statements in refactor