refactor and cleanup - next  part 2
parsing select code now takes into account what was actually selected
merged