Squeezed the function by removing useless repetitions