Fixed a segfaulting bug in drawing function (again)