added error check and changed ntrees