logic and selection working