added canvas resize logic