refactor to remove improper if fomat