first working and manually tested version