fix state on page load; split in js separate file