major refactoring and adding some more user fucntionality