JS code improvments