fixed bug in error handling, changed data transfer to js