Fixed the error handeling a bit