fixing null pointer issue on 0 and 1