added some not-dumb logic