first working hackish version. commit for discussion base