Refactored JS (NOT metro.js, it would have took too long)