Thread function corrected and seive implemented