fixed config parsing and added error handling