improved error handling in builder