Add onend and onerror