updated first post with some code snipz