added replace support. fixed foolish errors