fixed minor logic bug