add bounds checking functions, defined size at width*height