statistics and some error handling