added debugging code to js and controller