updates from main
Updated logic to fix bug