fixes #49, credit due to @willyg302