Removed redundancies from setAlarm function and move the code directly into the alarm function to remove redundant code usage.