Fixed indexing problem and orientation problem, although it still doesn't work