Cleaned up script including indention and slight improved method