moved js logic into application controller