Fixing logical bug