JS rewritten on OOP