filled in some logic