Streamlining code, removed unnecessary variables and lines