fix #261 and fix #249