updated for advance logic