refined javascript further