add overflow detection