breaking out more code from kr_interface.js