refactor the code to make it simple to use