add some documentation, improve error checking, add simple timer