refactored *view functions* and some general cleanup