refactor RDY state handling