fixed a bug (added flush stdin)