some changes to make it work when not encrypted as well