mihai's improvements in modal