add block function, move some other stuff