Move stock function to separate script