Simplified code by removing unneeded variables