merged contribution from @danipilze