more logic

more logic on the final phase