improved bbox handling