fix Promise and jQuery errors