added binflag column; sql not tested though