tried to compress too much logic