switch to using Sort
Using mask for IO