refactor using dynamically generated divs and enter method