refactor methods and add sample