Simplied some logic