initial commit of pipeline before optimisation
vectorised for loops, not getting a good result. will instead randomly sample bed data and do slow method