Fixed the while loop: working with theano now