Refactor code, no need for extra function