Correcetd sample code