add more documentation, also redirect sterr to a file