Resolve logic error. Fixes #410