HUGE logic error fixed