fixing bug in binning and adding function to calculate grid
adding seccondaty files