fixed some mistakes and made it use ajax