Refactored to reduce redundancy, added documentation, added another method for URL loading