drastic alterations and less code in progress, working version