fixing bug on first page where var was empty