Added overlfow/underflow checking