slight revamp, added logic