removed space and lines on nr_inmatric search + arranged better a nester ifs