fix potential bug with sub