code refactor for simpler method