added user friendly msgs and optamised code