refactor this in a method