Fixed file not found error and minor changes to logic