fixing error of extra end
removing redundant tests