Separate thread for the logic. To be done better.