revised segment boundary code