Completed basic atw logic