changed to use perl method instead of system