fixed errors in drawing functions