third program (slow)