initial working ugly version