Cleaned up code and removed unnecessary arrays