Based on the pull request #15 with added option to cancel rendering