improved modal functionality