Made code more concise and updated README with examples

The code does exactly what it does before but in a different way. The new way is much shorter.

Also added examples to the README.

works on python2 and python3 now