add js logic. a few issues with asynchronous vs synchronous code