Made API asynchronous. .validate now takes a callback