fixing the prog according to the requirements