fixed some error handeling