Removed system() usage and replaced it with better function. 

Once again, I edited the code in order to remove the usage of System() to make the code quality better. Although last time I changed it some one reversed the entire code. This should make the code more professional.