Formatted and idented all code for readability