adding remove functions and some bug fix