added initial code not fully tested though