presudo code for lexstat process