fix documentation and added more checks