Fixed magic bonus wrap around

Fixed issue with wrap around error for magic bonus.