fix cycle and prevent default bug