improved modal behaviour on layout