Modified to take arguments from stdin