Simplify the code
Fixes #1388