Update main.js

Made selectionObserver decision more elegant