Redesigned UI to use ListView and cleaned up code