implement patch by @fugue88
References #199