added exception for error handling + add error listener