Added logic for canvas