done more refactoring
Updated code to user index