Refact javascript code and html/css