Improvements to  my noob code