Fix #267 and fix #277
Fix #267 and fix #277