changed elseif to else to make sure sort runs