fix early return bug