Cleaned code and refactored

Made load into function with error since currently it does not work on
Opera or Chrome