refactor and add overflow