fix first selected, fix checking for tabs