Updated version with dialog