modified function putchar_i