refactor: generate method to have cleaner code