Wrote two helper functions