work on algorithm, updated ui