adding the previous code as is