another major overhaul, get this out of coffeescript