Got the basic idea working