Fixing canvas function issues