fixing num undefined