Latest functioning code.i fixed bugs
in alert generation component.
its now better not perfect