improve function structure
set canvas size in javascript