Added overflow protection