added ds functions and fixed bcs finding