Added a function to get the next available address