Updated Amelia code