add cfg settings and error handling