Updated to use html5 promises