Implemented Input buffer in scanner, more tests needed I think there is a race condition somewhere