add example, move the code around a bit to make the important stuff at the top