adding new features and a bit of clean up