Applying patch by Leonardo Tonetto <tonetto.dev at gmail.com> fixing
wrong casting.
Fix wrong casting (thanks to Leonardo Tonetto for spotting this error)