image viewer refactored in c