fixed ts strings
Improved error handling