added more code, organized stuff a little better.