Implement a selection menu function to reduce redundant code