Applying permission check fix suggested by flaggada in github issue #24.