changed javascript into HERE document for easier maintainance