initial code by zephir [ci skip]