added logic to GameThread.java