Fixes #783 - Logic error