Tidied up subset code