Implemented phase A and redid thread structure