remove scanf from read and clean up