adding the border and fixing the logic