first complete and tested version