Solving problem with combination of selection and adding