Implement fix suggested by magnum