improved error handling
replaced TODO comments