Using done where required; reformatted code