fixed index and some code