overflow handling implemented. Passed simple testing.