updated version, thanks to @viicviicviic