init

copy-pasted code from stackoverflow ftw!
http://stackoverflow.com/a/2451408/975935