Fixes minor logic bug