modefied logic on top