Changed code to handle schema change