write actually working code