bug fix 348 and 381