cleaned up some unused variables and conditions