Got rid of system() call, using popen()