Fix layout block validation error and optimise the js