Add logging
Move Tho's algo to another class