Updated to wrap EVERYTHING in if-fi statements.