Merged the last two lines of the function