added onError + fixes for localhost