added first version of working code