implements (almost) functioning version