Fix for #540
A proper fix for #540/#515
Merge pull request #542 from aodn/issue-540

Fix for #540