Added example and fixed a bug