moved over commit 204ecdc from dev branch