fixed bug in error handeling