Removed debug, updated logic