Cleaning up js to handle reply lookups