improve sample and main.js