Remove redundant variable and manipulation thereof