add some checks and write documentation