minor changes, added automatic selection