file tested ok, added comments