added main function to test and added offset to start from 0