fixed minor logic