still some errors. vaguely works