Restructure code for using the backbone framework