Updated onClick method to accommodate all button IDs
Cleaned up the code for maximum efficiency