stupid printing algo works