fixed bugs with selection