Cleaned up/fixed view function