An approach to minimize spaghetti code when using jQuery