test2 completedly debugged. final version for phase 2