added lib.graphics and error handling fix for lib.pattern