Moved event logic from EJS files