Update Main.java

added some more permission checks. :)