corrected hp comparision and changed order of calls