cleanup code a bit

Some formatting, some logic
previous was more clear