Remove undefined and redundant variable