added printing alerts, fixed indentation and organized the code to be more readble