$num var is not used in the rest of this file, why do you set this to 0?