Restore the first implementation by Jimx-, which was actually correct