add empty check and var name fix