completed implementation of next button