fixing bug with sprintf