Wondering how to separate concerns in javascript.