moved code from init-js to inline to make it more readable