added error handling + fixed docs