Added more checks
Changes to accept either file or url as argument