initial solution. not tested nor compiled.