js logic for views