separated js code and formatting