adding conditional for canvas to prevent NullPointer