some refactoring over logic and application.js