extract redundant code to method