improved error handeling