change code to use utility functions