Fixed js errors with preview