fixed bug with draw function