improve if formatting