Per romix's request regarding issue #218 here is the changed code via pull request

Code change for issue #218