Bug fix to main

fix #1008