Fix for #9422

After som help from @Pvince81 I managed to fix the bug in #1