First "working" version, need some polishing though