added replace label method and some other small things