Refactored to pass the ami id as a parameter instead of looking it up in a table