solution for the problem of remove element