Added logic to the top part.