Added example. and some bug fixing too