update and refactor quiz logic