refactor out dependencies on jquery and console