fixed typos and improved structure. now infinite loop somewhere.. :/