added first error handling todo: error handling and asserts