Attempt to fix bug #614161

Attempt to fix said bug for a college project. Apologies for possible wrong fix.