Fixed sensor array + cleaned up code