Added utility functions and additional comments