Helper function for python