refactored page show/hide into function