code refactor. added user model sorting and associated test