Prabin - added some more assertions and exiting when the assertions are not fulfilled