refactored and improved click flow