added code snippets from the internets