Refactor 2 methods into 1