fixed sprintf method