For issue #402 changed the code per @majenkotech recommendation