refactor the function and add more specs