Fixing embarassing error leading to crashes