changed code for removing extra lines