Added a third stage and better validation