Further error handeling refactor