Refactored the code to allow execution without using shell commands.