add code improvements by marcos