Forgot to take care of maintaining the by first index
Better error handling