simplified js code