avoided more unnecessary use of temp variables