Tested and fixed commit 4edab7635ab2e77e7074b559de5587050183f16f