updated for STDIN bug