fixed runtime overflow error
some improvements