slightly changed sub id code