finishing part of the logic