add level selection and more refactor