Added spawn function + error dialog