adding function to find the next available activity