fixing some indexing errors