fixed a bug in butterfly calc