refactoring and added show/hide functions