Slightly nicer code but does the same thing