updated to new logic